/* eslint-disable no-unused-vars */
import api from '@/api/index.js'
import { post, get, From, postJson,deleteData } from '@/api/request'//真实请求
const state = {
    address:[],
    orderInfo:{},
}

const mutations = {
    GETUSERADDRESS(state, data) {
        state.address = data
    },
    GETORDERINFO(state, data) {
        state.orderInfo = data
    }
}

const actions = {   
    getUserAddress({ commit }) {//获取用户地址列表
        return new Promise((resolve, reject) => {
            get(api.addressInfo).then(res => {
                if (res.code == 200) {
                    commit('GETUSERADDRESS', res.data)
                    resolve(res.data)
                }
            }).catch(err => {
                reject(err)
            })
        })
    },
    getOrderInfo({ commit }, data) {//获取订单交易页信息
        return new Promise((resolve, reject) => {
            get(api.orderInfo).then(res => {
                if (res.code == 200) {
                    commit('GETORDERINFO', res.data)
                    resolve(res.data)
                }
            }).catch(err => {
                reject(err)
            })
        })
    }
}

export default {
    state,
    mutations,
    actions
}
